<?php namespace Admin\Controller;

use Hdphp\Controller\Controller;

class LoginController extends Controller{

	public function index(){
		if(IS_POST){
			$_POST['logintime'] = time();
			$username = Q('post.username');
			$password = Q('post.password','','md5');
			$userData = Db::table('admin')->where("username='{$username}' AND password='{$password}'")->get();
			if($userData){
				$_SESSION['uid'] = $userData[0]['uid'];
				$_SESSION['account'] = $userData[0]['account'];
				$this->success('登录成功',U('./Admin/Index/index'));
			}
			$this->error('用户名或密码错误');
		}
		View::make();
	}

	public function out(){
    	session_unset();
    	session_destroy();
    	go(U('./Admin/Login/index'));
    }
}




 ?>